<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <include file="Public:meta"/>
</head>

<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<include file="Public:header"/>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <include file="Public:sidebar"/>
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- BEGIN PAGE CONTAINER-->
        <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
            <div class="row-fluid">
                 <!-- begin BCN -->
                <div class="row-fluid">
                    <div class="span12"><ul class="breadcrumb"><li><i class="icon-home"></i><a onfocus="blurLink(this);" href="{:U('Index/index')}">首页</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li><a onfocus="blurLink(this);" href="{:U(CONTROLLER_NAME . '/index', 'kept=1')}">{$ParentPageName|default="未命名"}</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li>{$PageName|default="未命名"}</li></ul></div>
                </div>
                <!-- end BCN -->
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="row-fluid white">
                <div class="span12">
                    <!-- begin 高级搜索 -->
                    <form id="filter_form" class="form-horizontal form-common adv-search-box" method="get" action="">
                        <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                        <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                        <input name="a" type="hidden" value="index">
                        <input name="filter" type="hidden" value="1">
                        <input name="type" type="hidden" value="{$Think.get.type}">
                        <div class="box">
                            <div class="portlet-title">
                                <div class="caption"><i class="icon-search"></i>高级搜索</div>
                                <div class="tools"><a href="javascript:;" class="collapse"></a></div>
                            </div>
                            <div class="portlet-body">
                                <div class="row-fluid">
                                    <div class="span8">
                                        <div class="control-group control-common">
                                            <label class="control-label"><span>活动时间段</span></label>
                                            <div class="controls">
                                                <div class="input-append form_date date-min" data-date="2012-12-21T15:25:00Z">
                                                    <input type="text" readonly="readonly" class="m-wrap w182" name="start" value="{$Think.get.start}" placeholder="开始时间" />
                                                    <span class="add-on"><i class="icon-remove"></i></span>
                                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                                </div>
                                                -
                                                <div class="input-append form_date date-max" data-date="2012-12-21T15:25:00Z">
                                                    <input type="text" readonly="readonly" class="m-wrap w182" name="end" value="{$Think.get.end}" placeholder="结束时间" />
                                                    <span class="add-on"><i class="icon-remove"></i></span>
                                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="search-actions">
                                    <button class="btn blue" id="filter" type="submit">筛选<i class="icon-filter"></i></button>
                                    <a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">重置</a>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- end 高级搜索 -->

                    <!-- begin 操作与分页 -->
                    <div class="row-fluid ">
                        <div class="dataTables_length pull-left">
                            <form id="limit_form" name="limit_form" method="post" action="">
                                <label for="limit_num">
                                    <select class="limit_num" id="limit_num" name="limit_num">
                                    <volist name="page_limit_num" id="vo">
                                        <option <eq name="_SESSION['page_limit_num']" value="$vo"> selected="selected" </eq> value="{$vo}">{$vo}</option>
                                    </volist>
                                    </select>
                                    个记录/每个页面
                                </label>
                            </form>
                        </div>
                        <div class="btn-item pull-left">
                            <eq name="_GET['category']" value="1">
                                <if condition="checkAccess(CONTROLLER_NAME,'add')">
                                    <a class="btn blue save" href="javascript:void(0);">添加<i class="icon-plus"></i></a>
                                </if>
                            </eq>
                        </div>
                        <div class="dataTables_filter pull-right">
                            <form id="search_form" class="search-form" name="search_form" method="get" action="">
                                <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                                <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                                <input name="a" type="hidden" value="{:(ACTION_NAME)}">
                                <input class="m-wrap search-input" type="text" placeholder="搜索..." name="keyword" value="{$Think.get.keyword}"/>
                                <button class="btn blue" id="search" type="submit">搜索</button><if condition="$Think.get.keyword neq ''"><a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">返回<i class="icon-share-alt"></i></a></if>
                            </form>
                        </div>
                    </div>
                    <!-- end 操作与分页 -->
                    
                    <div class="portlet-body">
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                            <tr>
                                <th><input type="checkbox" class="check_all" /></th>
                                <th>团类型</th>
                                <th>系统凑单</th>
                                <th>商品名称</th>
                                <th>团购价</th>
                                <!-- <th>团长立减金</th>
                                <th>团长价</th> -->
                                <th>拼团人数</th>
                                <!-- <th>限购数量</th>
                                <th>团购库存</th> -->
                                <th>优惠券</th>
                                <th>活动状态</th>
                                <th>活动时间</th>
                                <th>成团时效</th>
                                <th>已成团</th>
                                <!-- <th>团长福利</th>
                                <th>成团福利</th> -->
                                <th>操作</th>
                            </tr>
                            </thead>
                            <notempty name="list">
                                <tbody>
                                    <volist name="list" id="vo" key="k">
                                    <tr>
                                        <td><input type="checkbox" class="check_list" value="{$vo.id}" /></td>
                                        <td>
                                            <switch name="vo.type">
                                                <case value="1">普通团</case>
                                                <case value="2">神秘团</case>
                                                <default/>代理团
                                            </switch>
                                            <!-- <eq name="vo.type" value="1">
                                                普通团
                                            <else/>
                                                神秘团
                                            </eq> -->
                                        </td>
                                        <td>
                                            <neq name="vo.type" value="2">
                                                <eq name="vo.auto_group" value="1">
                                                    <span class="label label-success">是</span>
                                                <else/>
                                                    <span class="label label-inverse">否</span>
                                                </eq>
                                            <else/>
                                                --
                                            </neq>
                                        </td>
                                        <td>
                                            {$vo.goods_id|getTitle=###,Goods}
                                        </td>
                                        <td>
                                            <if condition="count($vo['info']) gt 1">
                                                <volist name="vo.info" id="v">
                                                    <div>{$v.assistant}:{$v.group_price}</div>
                                                </volist>
                                            <else/>
                                                <volist name="vo.info" id="v">
                                                    <div>{$v.group_price}</div>
                                                </volist>
                                            </if>
                                        </td>
                                        <!-- <td>
                                            <eq name="vo.type" value="1">
                                                {$vo.cut_money}
                                            <else/>
                                                --
                                            </eq>
                                        </td>
                                        <td>
                                            <eq name="vo.type" value="2">
                                                <if condition="count($vo['info']) gt 1">
                                                    <volist name="vo.info" id="v">
                                                        <div>{$v.assistant}:{$v.leader_price}</div>
                                                    </volist>
                                                <else/>
                                                    <volist name="vo.info" id="v">
                                                        <div>{$v.leader_price}</div>
                                                    </volist>
                                                </if>
                                            <else/>
                                                --
                                            </eq>
                                        </td> -->
                                        <td>
                                            {$vo.num}
                                        </td>
                                        <!-- <td>
                                            <eq name="vo.limit" value="0">
                                                不限
                                            <else/>
                                                {$vo.limit}
                                            </eq>
                                        </td>
                                        <td>
                                            <eq name="vo.type" value="3">
                                                不限
                                            <else/>
                                                {$vo.total}
                                            </eq>
                                            
                                        </td> -->
                                        <td>
                                            <eq name="vo.is_support_coupon" value="0">
                                                <span class="label label-inverse">不支持</span>
                                            <else/>
                                                <span class="label label-success">支持</span>
                                            </eq>
                                        </td>
                                        <td data-id="{$vo.id}">
                                            <if condition="checkAccess(CONTROLLER_NAME,'editStatus')">
                                                <div class="success-toggle-button">
                                                    <eq name="vo.hidden" value="0">
                                                        <input type="checkbox" class="toggle" checked="checked" name="hidden" value="0"/>
                                                    <else/>
                                                        <input type="checkbox" class="toggle"  name="hidden" value="1"/>
                                                    </eq>
                                                </div>
                                            <else/>
                                                <eq name="vo.hidden" value="0">
                                                    <span class="label label-success">开启</span>
                                                <else/>
                                                    <span class="label label-inverse">关闭</span>
                                                </eq>
                                            </if>
                                        </td>
                                        <td>
                                            {$vo.start|date="Y/m/d",###}-{$vo.end|date="Y/m/d",###}
                                        </td>
                                        <td>
                                            {$vo.expired}
                                        </td>
                                        <td>
                                            {$vo.count}
                                        </td>
                                        <!-- <td class="hidden-phone">
                                            <eq name="vo.type" value="1">
                                                --
                                            <else/>
                                                <gt name="vo.group_coupon_id" value="0">
                                                    {$vo.group_coupon_id|getTitle=###,Coupon}({$vo.group_coupon_id|getTitle=###,Coupon,money})
                                                <else/>
                                                    --
                                                </gt>
                                            </eq>
                                        </td>
                                        <td>
                                            <gt name="vo.coupon_id" value="0">
                                                {$vo.coupon_id|getTitle=###,Coupon}({$vo.coupon_id|getTitle=###,Coupon,money})
                                            <else/>
                                                --
                                            </gt>
                                        </td> -->
                                        <td class="hidden-phone">
                                             <div>
                                                <if condition="checkAccess(CONTROLLER_NAME, 'edit')">
                                                    <a class="btn green-stripe mini" href="{:U(CONTROLLER_NAME.'/edit', array('id'=>$vo['id']))}">详情</a>
                                                </if>
                                                <if condition="checkAccess(CONTROLLER_NAME, 'del')">
                                                    <in name="vo.type" value="1,2" >
                                                        <a class="btn red-stripe mini del" href="{:U(CONTROLLER_NAME.'/del', array('id'=>$vo['id']))}">删除</a>
                                                    </in>
                                                </if>
                                            </div>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </notempty>
                        </table>
                    </div>
                    <div class="pages clearfix">
                        <!-- <div class="control-group pull-left">
                            <div class="control-group pull-left">
                                <select class="list_op_type m-wrap">
                                    <option value="hide">关闭</option>
                                    <option value="not_hide">开启</option>
                                </select>
                                <button class="btn blue list_op">确定</button>
                            </div>
                        </div> -->
                        <include file="Public:page" />
                    </div>
                </div>
            </div>
            <!-- END PAGE CONTENT-->
        </div>
        <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
<!-- END CONTAINER -->
<div class="tips" style="display:none">
    <div class="content">
        <form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
            <div class="list">
                选择拼团类型
                <span class="close"></span>
            </div>
            <div class="list">
                <button type="button" class="btn green" onclick='prevView(1);'>普通团</button>
                <button type="button" class="btn green"  onclick='prevView(2);'>神秘团</button>
            </div>
        </form>
    </div>
</div>
<style type="text/css">
    .tips{
        position: absolute;
        top:0;
        left:0;
        width:100%;
        height: 100%;
        z-index:9999;
        color: #000;
    }
    .content{
        position: fixed;
        top:30%;
        left:40%;
        width:250px;
        height:150px;
        background: #f4f4f4;
        box-shadow:5px 2px 6px #000;
    }
    .content form{
        display: block;
        padding: 0;
        margin:0;
        width:100%;
        height:100%;
        border-radius: 8px;
    }
    .list{
        text-align: center;
        padding:15px 30px;
    }
    .list:last-child{
        display:flex;
        justify-content:space-between;
        align-items: center;
    }
</style>
<include file="Public:footer"/>
<include file="Public:js"/>
<script type="text/javascript" src="__TMPL__Public/scripts/layer/layer.js"></script>
<script type="text/javascript">
    $(function(){
         $('.content form .close').on('click',function(){
            $('.tips').hide();
        });
        $('a.save').on('click',function(){
            $('.tips').show();
        });
        initCss();
        $('body').on('change','.success-toggle-button input[name=hidden]',function(){
            var obj = $(this);
            var id = obj.closest('td').data('id');
            var style = obj.closest('div').attr('style');
            var flag = style.indexOf('0%');
            $.ajax({
                url:"{:U(CONTROLLER_NAME.'/editStatus')}",
                type:'post',
                dataType:'json',
                data:{
                    id:id
                },
                success:function(rs){
                    var msg = '开启成功';
                    if(flag >= 0){
                        msg = '关闭成功';
                    }
                    layer.msg(msg,{time:1000});
                }
            });
        })
    });
    function prevView(type){
        var url = "{:U(CONTROLLER_NAME.'/save',array('type' => 1))}";
        if(type == 2){
            url = "{:U(CONTROLLER_NAME.'/save',array('type' => 2))}";
        }
        window.location.href = url;
    }
    //初始化button_toggle样式
    function initCss(){
        var div_css = "width:80px;height:20px;line-height:20px";
        var label_css = "width:40px;height:20px;line-height:20px";
        $('.success-toggle-button').attr('style',div_css);
        $('.success-toggle-button span,.success-toggle-button label').attr('style',label_css);
    }
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>